﻿<navigation:Page
    xmlns:my2="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
    xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Ria"
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:my="clr-namespace:AdminApp.Web"
    xmlns:my1="clr-namespace:AdminApp.Web.Services" xmlns:AdminApp_Controls="clr-namespace:AdminApp.Controls"
    x:Class="AdminApp.Views.Events"
    d:DesignWidth="650.5"
    d:DesignHeight="480"
    Title="Events Page"
    >
    <my2:BusyIndicator
        IsBusy="{Binding DomainContext.IsLoading, ElementName=eventDomainDataSource}">
            <Grid
                x:Name="LayoutRoot">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition
                        Width="379" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition
                        Height="43" />
                </Grid.RowDefinitions>

                <riaControls:DomainDataSource
                    AutoLoad="True"
                    Height="0"
                    LoadedData="eventDomainDataSource_LoadedData"
                    x:Name="eventDomainDataSource"
                    QueryName="GetEventQuery"
                    Width="0"
                    Margin="50,2,320,240"
                    Grid.Row="1"
                    Grid.Column="1"
                    SubmittedChanges="eventDomainDataSource_SubmittedChanges">
                    <riaControls:DomainDataSource.DomainContext>
                        <my1:DigitalSignageDomainContext />
                    </riaControls:DomainDataSource.DomainContext>
                </riaControls:DomainDataSource>
                <data:DataGrid
                    AutoGenerateColumns="False"
                    ItemsSource="{Binding Data, ElementName=eventDomainDataSource}"
                    Margin="8"
                    x:Name="eventDataGrid"
                    RowDetailsVisibilityMode="VisibleWhenSelected"
                    DataContext="{Binding}"
                    Grid.ColumnSpan="1">
                    <data:DataGrid.Columns>

                        <data:DataGridTextColumn
                            x:Name="nameColumn"
                            Binding="{Binding Name}"
                            Header="Name"
                            Width="150" />

                        <data:DataGridTemplateColumn
                            x:Name="startDateColumn"
                            Header="Start Date"
                            Width="100">
                            <data:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <controls:DatePicker
                                        SelectedDate="{Binding StartDate, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" />
                                </DataTemplate>
                            </data:DataGridTemplateColumn.CellTemplate>
                        </data:DataGridTemplateColumn>

                        <data:DataGridTemplateColumn
                            x:Name="endDateColumn"
                            Header="End Date"
                            Width="100">
                            <data:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <controls:DatePicker
                                        SelectedDate="{Binding EndDate, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" />
                                </DataTemplate>
                            </data:DataGridTemplateColumn.CellTemplate>
                        </data:DataGridTemplateColumn>

                        <data:DataGridTextColumn
                            x:Name="descriptionColumn"
                            Binding="{Binding Description}"
                            Header="Description"
                            Width="300" />

                    </data:DataGrid.Columns>
                </data:DataGrid>
                <Grid
                    DataContext="{Binding SelectedItem, ElementName=eventDataGrid}"
                    Margin="8"
                    x:Name="_detailGrid" Grid.Column="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition
                            Width="95" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition
                            Height="Auto" />
                        <RowDefinition
                            Height="Auto" />
                        <RowDefinition
                            Height="Auto" />
                        <RowDefinition
                            Height="Auto" />
                    </Grid.RowDefinitions>

                    <TextBlock
                        Grid.Column="0"
                        Grid.Row="0"
                        HorizontalAlignment="Left"
                        Margin="3"
                        Text="Name:"
                        VerticalAlignment="Center" />
                    <TextBox
                        Grid.Column="1"
                        Grid.Row="0"
                        Height="23"
                        Margin="3,3,8,3"
                        x:Name="nameTextBox"
                        Text="{Binding Name, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
                        VerticalAlignment="Center" />

                    <TextBlock
                        Grid.Column="0"
                        Grid.Row="1"
                        HorizontalAlignment="Left"
                        Margin="3"
                        Text="Start Date:"
                        VerticalAlignment="Center" />
                    <controls:DatePicker
                        Grid.Column="1"
                        Grid.Row="1"
                        Height="23"
                        HorizontalAlignment="Left"
                        Margin="3"
                        x:Name="startDateDatePicker"
                        SelectedDate="{Binding StartDate, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
                        VerticalAlignment="Center"
                        Width="120" />

                    <TextBlock
                        Grid.Column="0"
                        Grid.Row="2"
                        HorizontalAlignment="Left"
                        Margin="3"
                        Text="End Date:"
                        VerticalAlignment="Center" />
                    <controls:DatePicker
                        Grid.Column="1"
                        Grid.Row="2"
                        Height="23"
                        HorizontalAlignment="Left"
                        Margin="3"
                        x:Name="endDateDatePicker"
                        SelectedDate="{Binding EndDate, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"
                        VerticalAlignment="Center"
                        Width="120" />

                    <TextBlock
                        Grid.Column="0"
                        Grid.Row="3"
                        HorizontalAlignment="Left"
                        Margin="3"
                        Text="Description:"
                        VerticalAlignment="Top" />
                    <TextBox
                        Grid.Column="1"
                        Grid.Row="3"
                        Margin="3,0,8,-310"
                        x:Name="descriptionTextBox"
                        Text="{Binding Description, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" />

                </Grid>
                <StackPanel
                    HorizontalAlignment="Left"
                    Margin="8,0,0,8"
                    x:Name="_eventPanel"
                    VerticalAlignment="Bottom"
                    Orientation="Horizontal"
                    Grid.Row="1">
                    <Button
                        Content="New Event"
                        x:Name="_addNew"
                        Click="_addNew_Click"
                        Margin="0" />
                    <Button
                        Content="Delete Event"
                        x:Name="_delete"
                        Click="_delete_Click"
                        Margin="0" />
                </StackPanel>

                <StackPanel
                    x:Name="_changesPanel"
                    HorizontalAlignment="Right"
                    Height="23"
                    Margin="0,0,8,8"
                    Orientation="Horizontal"
                    VerticalAlignment="Bottom"
                    Grid.Row="1"
                    Grid.Column="1"/>

            	<AdminApp_Controls:SaveAndRejectControl
            		Grid.Column="1"
            		Margin="0"
            		Grid.Row="1"
            		DataContext="{Binding ElementName=eventDomainDataSource}" HorizontalAlignment="Right" VerticalAlignment="Bottom" d:LayoutOverrides="VerticalAlignment" />

            </Grid>
    </my2:BusyIndicator>
</navigation:Page>
